dnl @synopsis AX_ERLANG_SUBST_ERTS_DIR
dnl
dnl Find the location of the Erlang ERTS directory.
dnl Based in part on the autoconf code from Romain Lenglet's
dnl Dryverl example project.
dnl
dnl This will set ERLANG_ERTS_DIR
dnl
dnl @author Hunter Morris  <huntermorris@gmail.com>
dnl @version 2008-03-18
AC_DEFUN([AX_ERLANG_SUBST_ERTS_DIR], [
    AC_REQUIRE([AC_ERLANG_SUBST_ROOT_DIR])[]
    AC_CACHE_CHECK([for Erlang/OTP ERTS directory], [erlang_cv_erts_dir], [
        AC_LANG_PUSH(Erlang)[]
        AC_RUN_IFELSE([
                AC_LANG_PROGRAM([], [
                    ERTSDir = code:root_dir()
                        ++ "/erts-"
                        ++ erlang:system_info(version),
                    file:write_file("conftest.out", ERTSDir),
                    halt(0)
                ])
            ],
            [erlang_cv_erts_dir=`cat conftest.out`],
            [AC_MSG_FAILURE([test Erlang program execution failed])]
        )
        AC_LANG_POP(Erlang)[]
    ])
    AC_SUBST([ERLANG_ERTS_DIR], [$erlang_cv_erts_dir])
])


